import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/public/public_alert.dart';
import 'package:honeypotflutter/public/views/public_appBar.dart';
import 'package:honeypotflutter/public/views/public_scrollView.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import '../../views/deliver_result_button.dart';
import '../../views/deliver_result_header.dart';
import '../../views/deliver_result_warning.dart';
import 'logic.dart';

class DeliverFailPage extends StatefulWidget {
  const DeliverFailPage({Key? key}) : super(key: key);

  @override
  State<DeliverFailPage> createState() => _DeliverFailPageState();
}

class _DeliverFailPageState extends State<DeliverFailPage> {
  final DeliverFailLogic logic = Get.put(DeliverFailLogic());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: MGColors.whileColor,
      appBar: HLAppBar(navigationTitle: "投递包裹", showBottomLine: true),
      body: HLScrollView(
        padding: EdgeInsets.only(left: 35, right: 35, top: 40),
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          DeliverResultHeader(
            status: "${logic.result?.displayAlias}格口",
            remind: "柜门已打开，请投递包裹后关门",
          ),
          SizedBox(height: 30),
          DeliverResultButton(
            firstTitle: "投递成功",
            firstAction: logic.sureAction,
            secondTitle: "再次开门",
            secondAction: logic.againOpenDoor,
            threeTitle: "未投递/取消",
            threeAction: () {
              HLAlert.showSheet(
                  title: "选择类型",
                  menuList: ["柜门未开,未投递", "柜门已开,格口不合适"],
                  action: (index, text) {
                    if (index == 0) {
                      logic.cancelDeliver(false);
                      return;
                    }
                    if (index == 1) {
                      logic.cancelDeliver(true);
                      return;
                    }
                  });
            },
          ),
          SizedBox(height: 20),
          DeliverResultWarning(
            remind: "请注意：当前网络信号弱，请确认是否投递成功，若已完成投递，请点击“投递成功”按钮;",
          ),
        ],
      ),
    );
    ;
  }

  @override
  void dispose() {
    Get.delete<DeliverFailLogic>();
    super.dispose();
  }
}
